﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotSpatial.Symbology;
using DotSpatial.Data;
using DotSpatial.Topology;
using DotSpatial.Controls;

namespace HAGISV2
{
    [Serializable]
    public class GridSourceSinksLayer : SingleBaseLayer
    {
        public GridSourceSinksLayer(string id, HyGrid hygrid, List<int[,]> boundary, List<int[]> dataIJKs,FMAPVIEW viewMode,int viewLayerIndex) :
            base(id)
        {
            _topColCoordinates = new List<Coordinate>();
            _leftRowCoordinates = new List<Coordinate>();
            _bottomCoordinates = new List<Coordinate>();
            _rightCoordinates = new List<Coordinate>();
            _gridLines = new List<LineSegment>();
            _gridCoordinates = new List<Coordinate>();
            _gridPolygons = new List<Polygon>();

            _hyGrid = hygrid;
            _boundary = GetNeededGridInfo.TranslateList2DTo3D(hygrid, boundary);
            _viewMode = viewMode;
            _featureType = FeatureType.Point;

            BuildDataset();

            _featureDataIndexes = new Dictionary<int[], int>();
            this.AddPoint(dataIJKs);

            switch (viewMode)
            {
                case FMAPVIEW.NORMAL:
                    _viewLayerIndex = viewLayerIndex;
                    GenerateNomalViewGrid();
                    break;
                case FMAPVIEW.FRONT:
                    _viewFrontIndex = viewLayerIndex;
                    GenerateFrontViewGrid(viewLayerIndex);
                    break;
                case FMAPVIEW.RIGHT:
                    _viewRightIndex = viewLayerIndex;
                    GenerateRightViewGrid(viewLayerIndex);
                    break;
                default:
                    break;
                    
            }
            OnSetInvalidBound();

            SetValidData();
        }



        #region 内部方法



        /// <summary>
        /// 设置无效区
        /// </summary>
        /// <returns></returns>
        bool OnSetInvalidBound()
        {
            try
            {
                switch (_viewMode)
                {
                    case FMAPVIEW.NORMAL:
                        _iBound = new int[_hyGrid.RowsCount, _hyGrid.ColsCount];
                        for (int j = 0; j < _hyGrid.RowsCount; j++)
                        {
                            for (int i = 0; i < _hyGrid.ColsCount; i++)
                            {
                                _iBound[j, i] = _boundary[_viewLayerIndex - 1, j, i];
                            }
                        }



                        break;
                    case FMAPVIEW.FRONT:
                        _iBound = new int[_hyGrid.LayersCount, _hyGrid.ColsCount];
                        for (int k = 0; k < _hyGrid.LayersCount; k++)
                        {
                            for (int i = 0; i < _hyGrid.ColsCount; i++)
                            {
                                _iBound[k, i] = _boundary[k, _viewFrontIndex - 1, i];
                            }
                        }

                        break;
                    case FMAPVIEW.RIGHT:
                        _iBound = new int[_hyGrid.LayersCount, _hyGrid.RowsCount];
                        for (int k = 0; k < _hyGrid.LayersCount; k++)
                        {
                            for (int j = 0; j < _hyGrid.RowsCount; j++)
                            {
                                //_iBound[k, _hyGrid.RowsCount - j - 1] = _boundary[k, j, _viewRightIndex - 1];
                                _iBound[k, j] = _boundary[k, j, _viewRightIndex - 1];
                            }
                        }
                        break;
                    default:
                        break;
                }

                _centroidPoints = GetNeededGridInfo.ComputeCentroidForLayerCells(_gridPolygons);

                int count = 0;
                for (int i = 0; i < _iBound.GetLength(0); i++)
                {
                    for (int j = 0; j < _iBound.GetLength(1); j++)
                    {
                        if (_iBound[i, j] == 0)
                            _centroidPoints[count] = (Point)Point.Empty;
                        count++;
                    }
                }

            }
            catch { return false; }
            return true;
        }


        bool GenerateFrontViewGrid(int rowIndex)
        {
            //不进行线段生成
            //生成点
            _gridCoordinates.Clear();
            _gridPolygons.Clear();

            if (_hyGrid.LayersCount <= 0 || _hyGrid.ColsCount <= 0) return false;

            Coordinate helpCoord;
            int row = rowIndex;
            for (int k = 0; k <= _hyGrid.LayersCount; k++)
            {
                for (int i = 0; i <= _hyGrid.ColsCount; i++)
                {
                    helpCoord = HyGrid.Grid3DCoordinates[k, row, i];
                    _gridCoordinates.Add(new Coordinate(helpCoord.X, helpCoord.Z));
                }
            }
            _colCountCell = _hyGrid.ColsCount;
            _rowCountCell = _hyGrid.LayersCount;

            Polygon cellPolygon;

            for (int i = 0; i < _hyGrid.LayersCount; i++)
            {
                for (int j = 0; j < _hyGrid.ColsCount; j++)
                {
                    cellPolygon = GetCellPolygon(i, j);

                    if (cellPolygon == null) return false;

                    _gridPolygons.Add(cellPolygon);
                }
            }



            return true;
        }

        bool GenerateRightViewGrid(int colIndex)
        {
            //不进行线段生成
            //生成点
            _gridCoordinates.Clear();
            _gridPolygons.Clear();

            if (_hyGrid.LayersCount <= 0 || _hyGrid.RowsCount <= 0) return false;


            Coordinate helpCoord;
            for (int k = 0; k <= _hyGrid.LayersCount; k++)
            {
                for (int j = 0; j <= _hyGrid.RowsCount; j++)
                {
                    helpCoord = HyGrid.Grid3DCoordinates[k, j, colIndex];
                    _gridCoordinates.Add(new Coordinate(helpCoord.Y, helpCoord.Z));
                }
            }

            _colCountCell = _hyGrid.RowsCount;
            _rowCountCell = _hyGrid.LayersCount;

            Polygon cellPolygon;

            for (int i = 0; i < _hyGrid.LayersCount; i++)
            {
                for (int j = 0; j < _hyGrid.RowsCount; j++)
                {
                    cellPolygon = GetCellPolygon(i, j);

                    if (cellPolygon == null) return false;

                    _gridPolygons.Add(cellPolygon);
                }
            }



            return true;
        }

        bool GenerateNomalViewGrid()
        {

            if (!GenerateGridBounder() || !GenerateGridLines() || !GenerateGridCoordinates() || !GenerateGridPolygons())
                return false;

            return true;
        }


        /// <summary>
        /// 生成点层
        /// </summary>
        /// <returns></returns>
        bool GenerateGridCoordinates()
        {
            try
            {
                Coordinate intersectCoordinate;
                _gridCoordinates.Clear();
                if (_rowCountCell <= 0 || _colCountCell <= 0) return false;
                //添加top
                _gridCoordinates.AddRange(_topColCoordinates);

                for (int i = 1; i < _rowCountCell; i++)
                {
                    //添加left
                    _gridCoordinates.Add(_leftRowCoordinates[i]);

                    for (int j = _rowCountCell + 2; j < _gridLines.Count - 1; j++)
                    {
                        intersectCoordinate = _gridLines[i].Intersection(_gridLines[j]);
                        _gridCoordinates.Add(intersectCoordinate);
                    }

                    //添加right
                    _gridCoordinates.Add(_rightCoordinates[i]);
                }

                //添加bot
                _gridCoordinates.AddRange(_bottomCoordinates);

            }
            catch
            {
                return false;
            }

            return true;
        }

        /// <summary>
        /// 生成线层
        /// </summary>
        /// <returns></returns>
        bool GenerateGridLines()
        {
            try
            {
                Coordinate[] twoCoordinates;
                _gridLines.Clear();
                for (int i = 0; i <= _rowCountCell; i++)
                {
                    twoCoordinates = new Coordinate[2] { _leftRowCoordinates[i], _rightCoordinates[i] };

                    _gridLines.Add(new LineSegment(_leftRowCoordinates[i], _rightCoordinates[i]));

                }
                for (int i = 0; i <= _colCountCell; i++)
                {
                    twoCoordinates = new Coordinate[2] { _topColCoordinates[i], _bottomCoordinates[i] };

                    _gridLines.Add(new LineSegment(_topColCoordinates[i], _bottomCoordinates[i]));

                }

            }
            catch
            {
                return false;
            }


            return true;
        }

        /// <summary>
        /// 生成面层
        /// </summary>
        /// <returns></returns>
        bool GenerateGridPolygons()
        {
            try
            {
                Polygon cellPolygon;
                _gridPolygons.Clear();

                for (int i = 0; i < _rowCountCell; i++)
                {
                    for (int j = 0; j < _colCountCell; j++)
                    {
                        cellPolygon = GetCellPolygon(i, j);

                        if (cellPolygon == null) return false;

                        _gridPolygons.Add(cellPolygon);

                    }
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
        /// <summary>
        /// 获取单元格多边形
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        Polygon GetCellPolygon(int row, int col)
        {
            if (row < 0 || col < 0 || row >= _rowCountCell || col >= _colCountCell) return null;
            Coordinate[] cellCoordinates = new Coordinate[5];
            try
            {
                cellCoordinates[0] = _gridCoordinates[row * (_colCountCell + 1) + col];
                cellCoordinates[1] = _gridCoordinates[row * (_colCountCell + 1) + col + 1];
                cellCoordinates[2] = _gridCoordinates[(row + 1) * (_colCountCell + 1) + col + 1];
                cellCoordinates[3] = _gridCoordinates[(row + 1) * (_colCountCell + 1) + col];
                cellCoordinates[4] = cellCoordinates[0];
            }
            catch
            {
                return null;
            }

            return new Polygon(new LinearRing(cellCoordinates));
        }

        /// <summary>
        /// 构建各边界点
        /// </summary>
        /// <returns></returns>
        bool GenerateGridBounder()
        {
            _topColCoordinates.Clear();
            _leftRowCoordinates.Clear();
            _rightCoordinates.Clear();
            _bottomCoordinates.Clear();

            try
            {
                if (_hyGrid.ColCoords.Length <= 0 || _hyGrid.RowCoords.Length <= 0) return false;
                Vector xVec;
                Vector yVec;
                if (_hyGrid.RotationZ % 360 == 0)
                {
                    xVec = new Vector(new Coordinate(0, 0), new Coordinate(1, 0));
                    yVec = new Vector(new Coordinate(0, 0), new Coordinate(0, 1));
                }
                else
                {
                    xVec = new Vector(Math.Cos(_hyGrid.RotationZ / 180 * Math.PI), Math.Sin(_hyGrid.RotationZ / 180 * Math.PI), 0);
                    yVec = new Vector(Math.Cos(_hyGrid.RotationZ / 180 * Math.PI + Math.PI / 2), Math.Sin(_hyGrid.RotationZ / 180 * Math.PI + Math.PI / 2), 0);
                }

                for (int i = _hyGrid.RowCoords.Length - 1; i >= 0; i--)
                {
                    //_leftRowCoordinates.Add(new Coordinate(_hyGrid.OrgX + yVec.X * (_hyGrid.RowCoords[i] - _hyGrid.OrgX), _hyGrid.OrgY + yVec.Y * (_hyGrid.RowCoords[i] - _hyGrid.OrgY)));
                    _leftRowCoordinates.Add(new Coordinate(_hyGrid.OrgX + yVec.X * _hyGrid.RowCoords[i], _hyGrid.OrgY + yVec.Y * _hyGrid.RowCoords[i]));

                }
                for (int i = 0; i < _hyGrid.ColCoords.Length; i++)
                {
                    //_bottomCoordinates.Add(new Coordinate(_hyGrid.OrgX + xVec.X * (_hyGrid.ColCoords[i] - _hyGrid.OrgX), _hyGrid.OrgY + xVec.Y * (_hyGrid.ColCoords[i] - _hyGrid.OrgY)));
                    _bottomCoordinates.Add(new Coordinate(_hyGrid.OrgX + xVec.X * _hyGrid.ColCoords[i], _hyGrid.OrgY + xVec.Y * _hyGrid.ColCoords[i]));
                }

                Vector vector = new Vector(_bottomCoordinates[0], _bottomCoordinates[_bottomCoordinates.Count - 1]);

                for (int i = 0; i < _leftRowCoordinates.Count; i++)
                {
                    _rightCoordinates.Add(_leftRowCoordinates[i] + vector);
                }
                vector = new Vector(_leftRowCoordinates[_leftRowCoordinates.Count - 1], _leftRowCoordinates[0]);
                for (int i = 0; i < _bottomCoordinates.Count; i++)
                {
                    _topColCoordinates.Add(_bottomCoordinates[i] + vector);
                }
                _rowCountCell = _leftRowCoordinates.Count - 1;
                _colCountCell = _topColCoordinates.Count - 1;

            }
            catch
            {
                return false;
            }
            return true;
        }





        protected void OnSetBoundary()
        {
            if (this.IsLoaded)
            {
                OnSetInvalidBound();
                SetValidData();
                (_iLayer as MapPointLayer).DataSet.InitializeVertices();
                _iLayer.Invalidate();
            }
        }



        void SetValidData()
         {
            _specialNeededDataIndexes = new List<int>();

            GetSpecialLayerData();
            (dataSet as FeatureSet).Features.Clear();

            for (int index = 0; index < _specialNeededDataIndexes.Count; index++)
            {
                if (_centroidPoints[_specialNeededDataIndexes[index]] != null&&_centroidPoints[_specialNeededDataIndexes[index]]!=Point.Empty)
                    (dataSet as FeatureSet).Features.Add(_centroidPoints[_specialNeededDataIndexes[index]]);
            }
        }

        protected override void OnSetVisible()
        {
            if (!this.IsLoaded)
            {
                return;
            }

            if (this._visiable && this._displayOptionVisible)
                this._iLayer.IsVisible = true;
            else
                this._iLayer.IsVisible = false;
        }

        protected override void OnViewModeChanged()
        {
            this.Redraw();
        }

        /// <summary>
        /// 获取指定层中索引数0123456...
        /// </summary>
        /// <returns></returns>
        void GetSpecialLayerData()
        {
            if (ViewLayerIndex <= 0) throw new ArgumentOutOfRangeException("层数", "此索引下限为1");

            if (_featureDataIndexes == null || _featureDataIndexes.Count <= 0) return;
            if (_specialNeededDataIndexes == null) _specialNeededDataIndexes = new List<int>();
            else _specialNeededDataIndexes.Clear();
            switch (_viewMode)
            {
                case FMAPVIEW.NORMAL:
                    foreach (int[] item in _featureDataIndexes.Keys)
                    {
                        if (item[2] == ViewLayerIndex && _featureDataIndexes[item] > 0)
                            _specialNeededDataIndexes.Add((item[0] - 1) * _hyGrid.ColsCount + item[1] - 1);
                    }
                    break;
                case FMAPVIEW.FRONT:
                    foreach (int[] item in _featureDataIndexes.Keys)
                    {
                        if (item[0] == ViewLayerIndex && _featureDataIndexes[item] > 0)
                            _specialNeededDataIndexes.Add((item[2] - 1) * _hyGrid.ColsCount + item[1] - 1);
                    }
                    break;
                case FMAPVIEW.RIGHT:
                    foreach (int[] item in _featureDataIndexes.Keys)
                    {
                        if (item[1] == ViewLayerIndex && _featureDataIndexes[item] > 0)
                            _specialNeededDataIndexes.Add((item[2] - 1) * _hyGrid.RowsCount +item[0]-1);
                        //_specialNeededDataIndexes.Add((item[2] - 1) * _hyGrid.RowsCount + _hyGrid.RowsCount - item[0]);
                    }
                    break;
                default:
                    break;
            }

        }

        void SetFeatureDisplayStyle()
        {
            this.SetFeatureDisplayStyle(_featureDisplayMode, _pointColor, _pointSize);
        }

        #endregion

        #region 公共方法

        public void ResetGridData(HyGrid grid, List<int[,]> boundary)
        {
            _hyGrid = grid;
            if (boundary == null || boundary.Count <= 0)
            {
                return;
            }
            else
            {
                this._boundary = new int[boundary.Count, boundary[0].GetLength(0), boundary[0].GetLength(1)];
                for (int k = 0; k < boundary.Count; k++)
                {
                    for (int j = 0; j < boundary[0].GetLength(0); j++)
                    {
                        for (int i = 0; i < boundary[0].GetLength(1); i++)
                        {
                            this._boundary[k, j, i] = boundary[k][j, i];
                        }
                    }
                }
            }


            this.Update();

        }

        public override bool OpenLayer()
        {
            this.BuildDataset();

            this.Update();

            this.Render();

            this.DefaultManager.CurrentMap.Invalidate();


            return true;
        }

        public override void Render()
        {
            base.Render();

            _iLayer.SelectionEnabled = false;

            SetFeatureDisplayStyle();
        }

        public override void StopRender()
        {
            base.StopRender();
        }

        public override void Redraw()
        {
            (this._dataSet as FeatureSet).Features.Clear();


            #region 生成网格信息并设置无效区
            
            switch (_viewMode)
            {
                case FMAPVIEW.NORMAL:
                    GenerateNomalViewGrid();
                    break;
                case FMAPVIEW.FRONT:
                    GenerateFrontViewGrid(ViewLayerIndex-1);
                    break;
                case FMAPVIEW.RIGHT:
                    GenerateRightViewGrid(ViewLayerIndex-1);
                    break;
                default:
                    break;

            }
            OnSetInvalidBound();

            SetValidData();

            #endregion

            //刷新视图

            if (_iLayer != null)
            {
                (_iLayer as MapPointLayer).DataSet.InitializeVertices();
                _iLayer.Invalidate();
            }
            

        }


        public override bool SaveLayer()
        {
            return base.SaveLayer();
        }


        /// <summary>
        /// 添加单个数据
        /// </summary>
        /// <param name="ijk"></param>
        public void AddPoint(int[] ijk)
        {
            if (_featureDataIndexes.ContainsKey(ijk)) 
                _featureDataIndexes[ijk]++;
            else _featureDataIndexes.Add(ijk, 1);

        }

        /// <summary>
        /// 添加多个数据
        /// </summary>
        /// <param name="ijks"></param>
        public void AddPoint(List<int[]> ijks)
        {
            foreach (int[] item in ijks)
            {
                AddPoint(item);
            }
        }
        /// <summary>
        /// 移除单个数据
        /// </summary>
        /// <param name="ijk"></param>
        public void RemovePoint(int[] ijk)
        {
            int haha = _featureDataIndexes.ContainsKey(ijk) ? (_featureDataIndexes[ijk] > 1 ? _featureDataIndexes[ijk]-- : (_featureDataIndexes.Remove(ijk) ? 1 : 0)) : 1;

        }

        /// <summary>
        /// 移除多个数据
        /// </summary>
        /// <param name="ijks"></param>
        public void RemovePoint(List<int[]> ijks)
        {
            foreach (int[] item in ijks)
            {
                RemovePoint(item);
            }

        }

        /// <summary>
        /// 清除数据
        /// </summary>
        public void ClearPoint()
        {
            _featureDataIndexes.Clear();

        }

        /// <summary>
        /// 设置层表现样式
        /// </summary>
        /// <param name="displayMode">形状</param>
        /// <param name="color"></param>
        /// <param name="size"></param>
        public void SetFeatureDisplayStyle(MFSOURCESINKSDISPLAYMODE displayMode,System.Drawing.Color color,double size)
        {
            if (_iLayer == null) _iLayer = this.DefaultManager.CurrentMap.Layers.Add(dataSet);
            MapPointLayer ptLayer = (MapPointLayer)_iLayer;
            _featureDisplayMode = displayMode;
            _pointColor = color;
            _pointSize = size;
            
            switch (displayMode)
            {
                case MFSOURCESINKSDISPLAYMODE.Diamond:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Diamond, size);
                    break;
                case MFSOURCESINKSDISPLAYMODE.Ellipse:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Ellipse, size);
                    break;
                case MFSOURCESINKSDISPLAYMODE.Hexagon:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Hexagon, size);
                    break;
                case MFSOURCESINKSDISPLAYMODE.Rectangle:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Rectangle, size);
                    break;
                case MFSOURCESINKSDISPLAYMODE.Pentagon:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Pentagon, size);
                    break;
                case MFSOURCESINKSDISPLAYMODE.Star:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Star, size);
                    break;
                case MFSOURCESINKSDISPLAYMODE.Triangle:
                    ptLayer.Symbolizer = new PointSymbolizer(color, DotSpatial.Symbology.PointShape.Triangle, size);

                    (ptLayer.Symbolizer as PointSymbolizer).Symbols[0].Angle = 30;

                    break;

                default:
                    break;
            }
        }



        #endregion

        #region 属性及字段

        bool _displayOptionVisible;
        /// <summary>
        /// 表现选项中设置的可见性
        /// </summary>
        public bool DisplayOptionVisible
        {
            get { return _displayOptionVisible; }
            set
            {
                _displayOptionVisible = value;
                OnSetVisible();
            }
        }

        int _rowCountCell;
        int _colCountCell;

        List<Polygon> _gridPolygons;

        /// 网格坐标点，左上角为0，0 依次向右向下排列
        List<Coordinate> _gridCoordinates;

        /// 添加顺序自上向下，自左向右，先横再丨
        List<LineSegment> _gridLines;

        /// 最上方一行坐标点信息
        List<Coordinate> _topColCoordinates;

        /// 最左方一列坐标点信息
        List<Coordinate> _leftRowCoordinates;

        List<Coordinate> _bottomCoordinates;

        List<Coordinate> _rightCoordinates;


        [NonSerialized]
        int[,] _iBound;
        
        int _viewLayerIndex = 1;
        int _viewFrontIndex = 1;
        int _viewRightIndex = 1;
        /// <summary>
        /// 索引从1开始
        /// </summary>
        public int ViewLayerIndex
        {
            get
            {
                switch (_viewMode)
                {
                    case FMAPVIEW.NORMAL:
                        return _viewLayerIndex > 1 ? _viewLayerIndex : 1;
                    case FMAPVIEW.FRONT:
                        return _viewFrontIndex > 1 ? _viewFrontIndex : 1;
                    case FMAPVIEW.RIGHT:
                        return _viewRightIndex > 1 ? _viewRightIndex : 1;
                    default:
                        return 1;
                }
            }
            set
            {
                if (value <= 0) return;
                switch (_viewMode)
                {
                    case FMAPVIEW.NORMAL:
                        if (value == _viewLayerIndex||value>_hyGrid.LayersCount) return;
                        _viewLayerIndex = value;

                        break;
                    case FMAPVIEW.FRONT:
                        if (value == _viewFrontIndex||value>_hyGrid.RowsCount) return;
                        _viewFrontIndex = value;
                        break;
                    case FMAPVIEW.RIGHT:
                        if (value == _viewRightIndex||value>_hyGrid.ColsCount) return;
                        _viewRightIndex = value;
                        break;
                    default:
                        return;
                }
                if (this.IsLoaded)
                {
                    this.Redraw();
                }
            }
        }

        int[, ,] _boundary;

        /// <summary>
        /// 网格单元有效性
        /// </summary>
        public int[, ,] Boundary
        {
            get { return _boundary; }

            set
            {
                this._boundary = value;
                this.OnSetBoundary();

            }

        }



        HyGrid _hyGrid;

        public HyGrid HyGrid
        {
            get { return _hyGrid; }
            set 
            { 
                _hyGrid = value;
                if (this.IsLoaded)
                {
                    this.Redraw();
                }
            }
        }

        /// <summary>
        /// 位置信息
        /// </summary>
        List<Point> _centroidPoints;
        
        public List<Point> CentroidPoints
        {
            get { return _centroidPoints; }
            set 
            { 
                _centroidPoints = value; 
            }
        }


        double _pointSize=10;

        public double PointSize
        {
            get { return _pointSize; }
            set
            {
                if (_pointSize == value) return;
                _pointSize = value; 
                SetFeatureDisplayStyle();
            }
        }

        System.Drawing.Color _pointColor=System.Drawing.Color.Green;

        public System.Drawing.Color PointColor
        {
            get { return _pointColor; }
            set
            {
                if (_pointColor == value) return;
                _pointColor = value;
                SetFeatureDisplayStyle();
            }
        }

        MFSOURCESINKSDISPLAYMODE _featureDisplayMode = MFSOURCESINKSDISPLAYMODE.Ellipse;

        public MFSOURCESINKSDISPLAYMODE FeatureDisplayMode
        {
            get { return _featureDisplayMode; }
            set
            {
                if (_featureDisplayMode == value) return;
                _featureDisplayMode = value; 
                SetFeatureDisplayStyle();
            }
        }



        // 具体切面层所用实体多边形Index
        List<int> _specialNeededDataIndexes;


        Dictionary<int[], int> _featureDataIndexes;
        /// <summary>
        /// key为IJK索引，value为个数
        /// </summary>
        public Dictionary<int[], int> FeatureDataIndexes
        {
            get { return _featureDataIndexes; }
        }

        #endregion
    }
}
